package cn.easyproject.easyee.sm.cmsmoudle.service.impl;

import java.util.List;
import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.easyproject.easyee.sm.cmsmoudle.criteria.SliderCriteria;
import cn.easyproject.easyee.sm.cmsmoudle.entity.Slider;
import cn.easyproject.easyee.sm.cmsmoudle.dao.SliderDAO;
import cn.easyproject.easyee.sm.cmsmoudle.service.SliderService;
import cn.easyproject.easyee.sm.base.service.BaseService;
import cn.easyproject.easyee.sm.base.pagination.PageBean;

/**
 * Slider Service, generated by EasyAuto
 * Must extends BaseService
 * 
 * @author easyproject.cn
 * @version 1.0
 *
 * 
 */
@Service("sliderService")
public class SliderServiceImpl extends BaseService implements SliderService {

		
	@Resource
	SliderDAO sliderDAO;

	@Override
	public void save(Slider slider) {
		sliderDAO.save(slider);
	}

	@Override
	public void delete(Serializable id) {
		sliderDAO.delete(id);
	}
	@Override
	public void delete(String[] values) {
		sliderDAO.deleteByIds(values);
	}
	
	@Override
	public void update(Slider o) {
		sliderDAO.update(o);
	}

	@Override
	public Slider get(Serializable id) {
		return sliderDAO.get(id);
	}

	@Override
	@SuppressWarnings("rawtypes")
	public void findByPage(PageBean pageBean, SliderCriteria sliderCriteria) {
		pageBean.setFrom(" web_slider ");
		pageBean.setSelect("*");
		pageBean.setEasyCriteria(sliderCriteria);
		
		// pagination
		sliderDAO.pagination(pageBean);
	}

	@Override
	public int findMaxRow() {
		return sliderDAO.findMaxRow();
	}
	
	@Override
	public int findMaxPage(int rowPerPage) {
		return (sliderDAO.findMaxRow()-1)/rowPerPage+1;
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Slider> findAll(){
		return sliderDAO.findAll();
	}

}
